<?php
/*

*/

namespace Home\Model;
use Think\Model;
class DocumentModel extends Model{


  public function selectData($where , $p,$n){
    if($p && $n){
      $datas = $this->where($where)->page($p.','.$n)->order('doc_id desc')->select();
    }
    else{
      $datas = $this->where($where)->order('doc_id desc')->select();
    }
    if($datas){
      return $datas;
    }
    else{
      return false;
    }
  }


  public function countData($where){
    $datas = $this->where($where)->count();
    if($datas){
      return $datas;
    }
    else{
      return false;
    }
  }

  public function sumMoney($where){
    $data = $this -> where($where)-> sum('amount');
    if($data){
      return $data;
    }
  }

  public function saveDoc($id,$data){
      $save = $this -> where(array('doc_id'=>$id))->save($data);
      if($save){
          return true;
      }
      else{
          return false;
      }

  }



















}
